const mysql = require("mysql");

var con = mysql.createConnection({
    host: "localhost",
    port: 3306,
    user: "root",
    password: "123456",
    database: "blog12"
})

var db = {};
db.query = async function(sqlStr, arr) {
    return await new Promise((resolve, reject) => {
		con.query(sqlStr, arr, (err, result) => {
			if(err) {
				reject(err);
			}
			else {
				resolve(result);
			}
		})
	})
}

module.exports = db;